package com.tjmc.recruit.user.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tjmc.recruit.common.core.util.R;
import com.tjmc.recruit.common.log.annotation.SysLog;
import com.tjmc.recruit.user.dto.ResumeSearchDTO;
import com.tjmc.recruit.user.service.IResumeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

@RestController
@RequiredArgsConstructor
@RequestMapping("/resume")
@Tag(description = "resume", name = "简历管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class ResumeController {
    private final IResumeService resumeService;

    /**
     * 根据用户Id查询简历信息
     *
     * @param userId 用户ID
     * @return
     */
    @Operation(summary = "根据用户Id查询简历信息", description = "根据用户Id查询简历信息")
    @GetMapping("/{userId}")
    @SysLog("根据用户Id查询简历信息")
    public R getResumeByUserId(@PathVariable Long userId, @ParameterObject Long companyId) {
        return R.ok(resumeService.getPersonalInfoByUserId(String.valueOf(userId), companyId));
    }


    /**
     * 简历库列表接口
     *
     * @param page      分页参数
     * @param searchDTO 查询条件
     * @return
     */
    @Operation(summary = "简历库列表", description = "简历库列表")
    @GetMapping("/all/page")
    @SysLog("简历库列表")
    public R getResumeAllPage(@ParameterObject Page page, @ParameterObject ResumeSearchDTO searchDTO) {
        return R.ok(resumeService.searchPage(page, searchDTO));
    }

    /**
     * 企业推荐简历列表
     * @param page
     * @param companyId
     * @return
     */
    @Operation(summary = "企业推荐简历列表", description = "企业推荐简历列表")
    @GetMapping("/recommends/page")
    @SysLog("企业推荐简历列表")
    public R getRecommendResume(@ParameterObject Page page, @ParameterObject Long companyId) {
        return R.ok(resumeService.getRecommendsResumePage(page, companyId));
    }

    /**
     * 企业查询简历手机号
     * @param accountId 被查看者ID
     * @param eNum 消耗E币数
     * @return
     */
    @Operation(summary = "企业查询简历手机号" , description = "企业查询简历手机号" )
    @SysLog("企业查询简历手机号" )
    @GetMapping("/checkResumePhone")
    public R companyCheckResumePhone(@ParameterObject Long accountId, @ParameterObject BigDecimal eNum) {
        return R.ok(resumeService.checkPhoneByAccountId(accountId, eNum));
    }


    @Operation(summary = "简历刷新" , description = "简历刷新" )
    @SysLog("简历刷新" )
    @GetMapping("/refresh/{accountId}")
    public R refreshResume(@ParameterObject Long accountId) {
        return R.ok(resumeService.refreshResume(accountId));
    }

}
